package com.lz.service.zhy.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lz.entity.Employee;
import com.lz.repository.zhy.EmployeeInfoDao;
import com.lz.service.zhy.EmployeeInfoService;
//使用@Service注解在Spring容器中注册名为userInfoService的UserInfoServiceImpl实例
@Service
public class EmployeeInfoServiceImpl implements EmployeeInfoService {

	
	//使用@Autowired注解注入EmployeeInfoDAOImpl实例
	@Autowired
	EmployeeInfoDao employeeInfoDao;
	@Autowired
	SessionFactory sessionFactory;
	
	@Override
	public Employee employee(Employee employee) {
		Session session = sessionFactory.openSession();
		Query query = session.createQuery("from Employee as el where el.employeeName=:employeeName and el.password=:password");
		query.setParameter("employeeName", employee.getEmployeeName());
		query.setParameter("password", employee.getPassword());
		Employee employee1 =(Employee) query.uniqueResult();
		session.close();
		return  employee1;
	}

}
